<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <script src="../plugins/echarts/echarts.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div id="calendar" class="block">
        <!--<span class="demonstration">带快捷选项</span>-->
        <div id="startDate" class="v1" hidden="hidden">{{ value1[0] }}</div>
        <div id="endDate" class="v2" hidden="hidden">{{ value1[1] }}</div>
        <el-date-picker
                v-model="value1"
                type="daterange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
        </el-date-picker>
        <button type="button" onclick="checkByDate()">点击查询</button>
    </div>

    <div class="content-header">
        <h1>统计分析<small>会员数量</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员数量</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:600px;"></div>
        </div>
    </div>
    <!--    <div class="app-container">-->
    <!--        <div class="box">-->
    <!--            &lt;!&ndash; 为 ECharts 准备一个具备大小（宽高）的 DOM &ndash;&gt;-->
    <!--            <div id="chart2" style="height:600px;"></div>-->
    <!--        </div>-->
    <!--    </div>-->
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script>
    var Main = {
        data() {
            return {
                pickerOptions: {
                    shortcuts: [{
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近六个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90 * 2);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近十二个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90 * 4);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                value1: '',
                value2: ''
            };
        }
    };
    var Ctor = Vue.extend(Main)
    new Ctor().$mount('#calendar')
</script>

<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('chart1'));

    // 使用刚指定的配置项和数据显示图表。
    var memberOption = {
        title: {
            text: '会员数量'
        },
        tooltip: {},
        legend: {
            data: ['会员数量']
        },
        xAxis: {
            data: ["2018.01", "2018.02", "2018.03", "2018.04"]
        },
        yAxis: {
            type: 'value'
        },
        series: [{
            name: '会员数量',
            type: 'line',
            data: [13, 14, 28, 30]
        }]
    };
    myChart1.setOption(memberOption);

    axios.get("http://localhost:9002/report/getMemberReport.do").then((res) => {
        if (res.data.flag) {
            //myChart1.setOption();
            memberOption.xAxis.data = res.data.data.months;
            memberOption.series[0].data = res.data.data.memberCount;
            myChart1.clear();
            myChart1.setOption(memberOption);
        }
    });

    // checkByDate();

    function checkByDate() {
        var param = {
            startDate: document.getElementById('startDate').innerText,
            endDate: document.getElementById('endDate').innerText
        };

        // alert(param.startDate);
        // alert(param.endDate);
        axios.get("http://localhost:9002/report/getMemberReportByDate.do", {params: param}).then((res) => {
            if (res.data.flag) {
                //myChart1.setOption();
                memberOption.xAxis.data = res.data.data.months;
                memberOption.series[0].data = res.data.data.memberCount;
                myChart1.clear();
                myChart1.setOption(memberOption);
            }
        });
    }
</script>

<!--<script type="text/javascript">-->
<!--    // 基于准备好的dom，初始化echarts实例-->
<!--    var myChart2 = echarts.init(document.getElementById('chart2'));-->

<!--    // 使用刚指定的配置项和数据显示图表。-->
<!--    function getVirtulData(year) {-->
<!--        year = year || '2017';-->
<!--        var date = +echarts.number.parseDate(year + '-01-01');-->
<!--        var end = +echarts.number.parseDate((+year + 1) + '-01-01');-->
<!--        var dayTime = 3600 * 24 * 1000;-->
<!--        var data = [];-->
<!--        for (var time = date; time < end; time += dayTime) {-->
<!--            data.push([-->
<!--                echarts.format.formatTime('yyyy-MM-dd', time),-->
<!--                Math.floor(Math.random() * 1000)-->
<!--            ]);-->
<!--        }-->
<!--        console.log(data[data.length - 1]);-->
<!--        return data;-->
<!--    }-->


<!--    var graphData = [-->
<!--        [-->
<!--            1485878400000,-->
<!--            260-->
<!--        ],-->
<!--        [-->
<!--            1486137600000,-->
<!--            200-->
<!--        ],-->
<!--        [-->
<!--            1486569600000,-->
<!--            279-->
<!--        ],-->
<!--        [-->
<!--            1486915200000,-->
<!--            847-->
<!--        ],-->
<!--        [-->
<!--            1487347200000,-->
<!--            241-->
<!--        ],-->
<!--        [-->
<!--            1487779200000,-->
<!--            411-->
<!--        ],-->
<!--        [-->
<!--            1488124800000,-->
<!--            985-->
<!--        ]-->
<!--    ];-->

<!--    var links = graphData.map(function (item, idx) {-->
<!--        return {-->
<!--            source: idx,-->
<!--            target: idx + 1-->
<!--        };-->
<!--    });-->
<!--    links.pop();-->

<!--    option = {-->
<!--        tooltip: {-->
<!--            position: 'top'-->
<!--        },-->

<!--        visualMap: [{-->
<!--            min: 0,-->
<!--            max: 1000,-->
<!--            calculable: true,-->
<!--            seriesIndex: [2, 3, 4],-->
<!--            orient: 'horizontal',-->
<!--            left: '55%',-->
<!--            bottom: 20-->
<!--        }, {-->
<!--            min: 0,-->
<!--            max: 1000,-->
<!--            inRange: {-->
<!--                color: ['grey'],-->
<!--                opacity: [0, 0.3]-->
<!--            },-->
<!--            controller: {-->
<!--                inRange: {-->
<!--                    opacity: [0.3, 0.6]-->
<!--                },-->
<!--                outOfRange: {-->
<!--                    color: '#ccc'-->
<!--                }-->
<!--            },-->
<!--            seriesIndex: [1],-->
<!--            orient: 'horizontal',-->
<!--            left: '10%',-->
<!--            bottom: 20-->
<!--        }],-->

<!--        calendar: [{-->
<!--            orient: 'vertical',-->
<!--            yearLabel: {-->
<!--                margin: 40-->
<!--            },-->
<!--            monthLabel: {-->
<!--                nameMap: 'cn',-->
<!--                margin: 20-->
<!--            },-->
<!--            dayLabel: {-->
<!--                firstDay: 1,-->
<!--                nameMap: 'cn'-->
<!--            },-->
<!--            cellSize: 40,-->
<!--            range: '2017-02'-->
<!--        },-->
<!--            {-->
<!--                orient: 'vertical',-->
<!--                yearLabel: {-->
<!--                    margin: 40-->
<!--                },-->
<!--                monthLabel: {-->
<!--                    margin: 20-->
<!--                },-->
<!--                cellSize: 40,-->
<!--                left: 460,-->
<!--                range: '2017-01'-->
<!--            },-->
<!--            {-->
<!--                orient: 'vertical',-->
<!--                yearLabel: {-->
<!--                    margin: 40-->
<!--                },-->
<!--                monthLabel: {-->
<!--                    margin: 20-->
<!--                },-->
<!--                cellSize: 40,-->
<!--                top: 350,-->
<!--                range: '2017-03'-->
<!--            },-->
<!--            {-->
<!--                orient: 'vertical',-->
<!--                yearLabel: {-->
<!--                    margin: 40-->
<!--                },-->
<!--                dayLabel: {-->
<!--                    firstDay: 1,-->
<!--                    nameMap: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']-->
<!--                },-->
<!--                monthLabel: {-->
<!--                    nameMap: 'cn',-->
<!--                    margin: 20-->
<!--                },-->
<!--                cellSize: 40,-->
<!--                top: 350,-->
<!--                left: 460,-->
<!--                range: '2017-04'-->
<!--            }],-->

<!--        series: [{-->
<!--            type: 'graph',-->
<!--            edgeSymbol: ['none', 'arrow'],-->
<!--            coordinateSystem: 'calendar',-->
<!--            links: links,-->
<!--            symbolSize: 10,-->
<!--            calendarIndex: 0,-->
<!--            data: graphData-->
<!--        }, {-->
<!--            type: 'heatmap',-->
<!--            coordinateSystem: 'calendar',-->
<!--            data: getVirtulData(2017)-->
<!--        }, {-->
<!--            type: 'effectScatter',-->
<!--            coordinateSystem: 'calendar',-->
<!--            calendarIndex: 1,-->
<!--            symbolSize: function (val) {-->
<!--                return val[1] / 40;-->
<!--            },-->
<!--            data: getVirtulData(2017)-->
<!--        }, {-->
<!--            type: 'scatter',-->
<!--            coordinateSystem: 'calendar',-->
<!--            calendarIndex: 2,-->
<!--            symbolSize: function (val) {-->
<!--                return val[1] / 60;-->
<!--            },-->
<!--            data: getVirtulData(2017)-->
<!--        }, {-->
<!--            type: 'heatmap',-->
<!--            coordinateSystem: 'calendar',-->
<!--            calendarIndex: 3,-->
<!--            data: getVirtulData(2017)-->
<!--        }]-->
<!--    };-->
<!--    myChart2.setOption(option);-->
<!--</script>-->
</html>
